/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package 解析.node.charproperty;

import java.io.Serializable;
import 解析.Matcher;
import 解析.node.node.Node;
import 解析.node.others.TreeInfo; 

/**
 *
 * @author yanxi
 */
public abstract class CharProperty extends Node implements Serializable {
    private static final long serialVersionUID = 1000;
    
    public abstract boolean isSatisfiedBy(int ch); 
    /*
    public CharProperty complement() {
        
        
        CharProperty cc=this;
        
        return new CharProperty() { 
            @Override
            public boolean isSatisfiedBy(int ch) {
                return !CharProperty.this.isSatisfiedBy(ch);
            }
            
            @Override
            public ObservableList<PropertyAbstract属性> getTableView属性记录List(){
                super.getTableView属性记录List();
                this.节点类型="[补集]"+cc.getClass().getName();
                ObservableList<PropertyAbstract属性> temp=cc.getTableView属性记录List(); 
                for(int i=0;i<temp.size();i++){
                    if(temp.get(i).getName().equals("节点类型")){
                        temp.remove(i);
                        break;
                    } 
                }
                for(int i=0;i<temp.size();i++){
                    if(temp.get(i).getName().equals("是补集")){
                        temp.remove(i);
                        break;
                    } 
                }
                this.tableView属性记录List.addAll(temp);
                return this.tableView属性记录List;
            }
            
            @Override
            public String toString(){
                return "[补集]"+cc.toString();
            }
        };
    } */

    @Override
    public boolean match(Matcher matcher, int i, CharSequence seq) {
        if (i < matcher.to) {
            int ch = Character.codePointAt(seq, i);
            return isSatisfiedBy(ch)
                    && next.match(matcher, i + Character.charCount(ch), seq);
        } else {
            matcher.hitEnd = true;
            return false;
        }
    }

    @Override
    public boolean study(TreeInfo info) {
        info.minLength++;
        info.maxLength++;
        return next.study(info);
    } 
}
